package com.glodon.cad.paper.converter;

import com.glodon.cad.paper.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author: zhouj-j
 * @version: 2018/4/17 9:31
 */
@Component
public class UserConverter implements Converter<String, User> {

    @Override
    public User convert(String s) {
        String[] parts = s.split(";");
        if (parts.length == 2) {
            User user = new User();
            user.setName(parts[0]);
            user.setAge(Integer.valueOf(parts[1]));
            return user;
        }
        return null;
    }
}
